package com.ddlaw.util;

import java.util.HashMap;
import java.util.Set;

import com.cloopen.rest.sdk.CCPRestSmsSDK;




public class MsgSend {
		/*服务器地址(测试)*/  
//		private static final String Rest_URL ="sandboxapp.cloopen.com";
		/*服务器地址(生产)*/  
		private static final String Rest_URL ="app.cloopen.com";
		/*服务器端口*/  
		private static final String Rest_PORT ="8883";
		/*主账号ACOUNT SID*/  
		private static final String ACOUNT_SID ="8a48b55149f50bf3014a0a07ee490f66";
		/*主账号AUTH TOKEN*/  
		private static final String AUTH_TOKEN ="10ad71afbd044183820468dfa996f156";
		/*应用APP ID(测试)*/  
//		private static final String APP_ID ="8a48b55149f50bf3014a0a0815120f6a";
		/*应用APP ID(生产)*/  
		private static final String APP_ID ="8a48b5514d32a2a8014d6b358d832846";
		
		@SuppressWarnings("unchecked")
		public static int SMS(String tel,String msgId,String[] msg){
			//初始化SDK
			CCPRestSmsSDK restAPI = new CCPRestSmsSDK();
			HashMap<String, Object> result = null;
			restAPI.init(Rest_URL,Rest_PORT);
			restAPI.setAccount(ACOUNT_SID, AUTH_TOKEN);
			restAPI.setAppId(APP_ID);
			result = restAPI.sendTemplateSMS(tel,msgId ,msg);
			if("000000".equals(result.get("statusCode"))){
				//正常返回输出data包体信息（map）
				HashMap<String,Object> data = (HashMap<String, Object>) result.get("data");
				Set<String> keySet = data.keySet();
				for(String key:keySet){
					Object object = data.get(key);
					System.out.println(key +" = "+object);
				}
				 return 1;
			}else{
				//异常返回输出错误码和错误信息
				System.out.println("错误码=" + result.get("statusCode") +" 错误信息= "+result.get("statusMsg"));
				return 0;
				 
			}
		
		}
}
